import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '../views/Layout/index.vue'
import Login from '../views/Login/Login.vue'
Vue.use(VueRouter)
const Home=()=>import('../views/Home/Home.vue')
const Goods=()=>import('../views/Goods/Goods.vue')
const Advert=()=>import('../views/Advert/Advert.vue')
const Order=()=>import('../views/Order/Order.vue')
const OrderList=()=>import('../views/Order/OrderList/index.vue')
const OrderBack=()=>import('../views/Order/OrderBack/index.vue')
const Params=()=>import('../views/Params/Params.vue')
const AddGood=()=>import('../views/Goods/views/addGood.vue')
const routes = [
  {
    path:'',
    component:Layout,
    children:[
      {
        path:'/',
        name:'Home',
        component:Home
      },
      {
        path:'/goods',
        name:'Goods',
        component:Goods
      },
      {
        path:'/addgood/:isShow',
        name:'AddGood',
        component:AddGood
      },
      {
        path:'/advert',
        name:'Advert',
        component:Advert
      },
      {
        path:'/order',
        name:'Order',
        component:Order,
        children:[
          {
            path:'orderlist',
            component:OrderList
          },
          {
            path:'orderback',
            component:OrderBack
          }
        ]
      },
      {
        path:'/params',
        name:'Params',
        component:Params
      },
      
    ]
  },
  {
    path:'/login',
    name:'Login',
    component:Login
  }
]

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
